#include <stdio.h>

int get_max_num_index(int *arr, int n)
{
    int max_num = arr[0];
    int pos = 0;
    for (int i = 1; i < n; i++)
    {
        if (arr[i] > max_num)
        {
            max_num = arr[i];
            pos = i;
        }
    }
    return pos;
}
/**
 * 选择一个最大的
 */
void select(int *arr, int n)
{
    while (n > 1)
    {
        int pos = get_max_num_index(arr, n);
        int t = arr[pos];
        arr[pos] = arr[n - 1];
        arr[n - 1] = t;
        --n;
    }
}

int main()
{
    int arr[] = {
        3,
        7,
        4,
        2,
        6,
        1,
    };
    select(arr, 6);
    for (int i = 0; i < 6; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}